<!--清算排队管理申请录入页面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      defaultEventKey="sapsTable"
    ></ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      defaultEventKey="sapsTable"
    >
      <template v-slot:operate>
        <el-table-column
          label="操作"
          align="center"
          width="120"
          fixed="right"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
            {
            label: '明细',
            // permission: 'user:xxx:xxx',
            doFunc: () => {
            handleAction('detials', scope.row);
            }
            },
            {
            label: '清算管理',
            visible: scope.row.totalNum > 0 && scope.row.rcvType === '05',
            // permission: 'user:xxx:xxx',
            doFunc: () => {
            handleAction('queueManage', scope.row);
            }
            },
            ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 明细弹出框 -->
    <details-dialog
      ref="detailsDialog"
      :dictMap="dictMap"
      :isNets="false"
      :formData.sync="formData"
    ></details-dialog>
    <!-- 清算管理弹出框 -->
    <saps-manage-dialog
      ref="sapsManageDialog"
      :dictMap="dictMap"
      :pkgId="pkgId"
      @editComplete="editComplete"
    ></saps-manage-dialog>
    <!-- 查询申请弹框 -->
    <send-apply-dialog ref="sendApplyDialog" :dictMap="dictMap" @editComplete="editComplete"></send-apply-dialog>
  </div>
</template>
<script>
import { apiUrlConfig } from "@/api/cnaps/nets/queueMng/saps_queue_manage_entry.js";
import DetailsDialog from "./components/details";
import SapsManageDialog from "./components/sapsManage";
import SendApplyDialog from "./components/sendApply";
import { listPageMixin } from "@/libs/listPageMixin";
import { log } from "util";

export default {
  name: "netsQueueManageEntry",
  mixins: [listPageMixin],
  components: {
    DetailsDialog,
    SapsManageDialog,
    SendApplyDialog
  },
  data() {
    return {
      pkgId: "",
      reqConfig: apiUrlConfig,
      total: 0,
      dataList: [],
      //数据字典
      searchFormDictList: ["PKG_STATUS", "PROCESSSTATUS", "CLS_QUERYTYPE"],
      //  明细弹框数据
      // form表单字段
      formData: {
        id: "",
        pkgId: "",
        vdate: "",
        workdate: "",
        inqStBrno: "",
        totalNum: "",
        sndTime: "",
        inqType: "",
        rcvType: "",
        procStatus: "",
        remarks: "",
        rejectInfo: ""
      },
      showSearch: true,
      // 查询参数
      queryParams: {
        vdate: "",
        vdate1: "",
        workdate: "",
        workdate1: ""
      },
      formOptions: [],
      opButtonList: () => {
        return [
          {
            label: "发送查询申请",
            type: "primary",
            icon: "",
            // permission: "user:xxx:xxx",
            clickFun: () => {
              this.handleAction("sendApply");
            }
          }
        ];
      },
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "170", sortable: false },
        {
          label: `CPG日期`,
          prop: "vdate",
          width: "100",
          sortable: false,
          type: "date"
        },
        {
          label: `工作日期`,
          prop: "workdate",
          width: "160",
          sortable: false,
          type: "date"
        },
        { label: `被查询行`, prop: "inqStBrno", width: "160", sortable: false },
        {
          label: `查询方式`,
          prop: "inqType",
          width: "100",
          dictCode: "CLS_QUERYTYPE",
          sortable: false
        },
        {
          label: `排队业务数目`,
          prop: "totalNum",
          width: "160",
          sortable: false
        },
        {
          label: `申请时间`,
          prop: "sndTime",
          width: "160",
          sortable: false,
          type: "date"
        },
        {
          label: `通讯状态`,
          prop: "rcvType",
          width: "100",
          dictCode: "PKG_STATUS",
          sortable: false
        },
        {
          label: `中心状态`,
          prop: "procStatus",
          dictCode: "PROCESSSTATUS",
          sortable: false
        }
      ]
    };
  },
  mounted() {
    this.formOptions = [
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate1"
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd"
        }
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "vdate",
          endTimeName: "vdate1"
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd"
        }
      }
    ];
  },
  methods: {
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },
    /** 明细按钮操作 */
    toEdit(row) {
      this.$refs.detailsDialog.show();
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "sendApply":
          // 查询申请
          this.$refs.sendApplyDialog.show();
          break;
        case "detials":
          // 明细信息
          this.formData = _.clone(row);
          this.$refs.detailsDialog.show();
          break;
        case "queueManage":
          // 排队管理
          this.pkgId = row.pkgId;
          this.$refs.sapsManageDialog.show();
          break;
      }
    }
  }
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
